var addgroupmsg = function () {

    rowid = $('.toolbartoken').data('toolbar').grid.jqGrid('getGridParam', 'selrow');
    if (!rowid) {
        return sy.tip('请选择要发送信息的记录!', 'warning');
    }

    var url = sy.url({
        a: "addGroupMsg",
        param: { id: rowid }
    });

    var opt = $.extend({
        title: '发送信息',
        cancel: true,
        button: [{
            name: '发送',
            class: "btn-outline-primary",
            submit: true,
            close: true,
            toolbar: $('.toolbartoken').data('toolbar'),
            click: function (e, iframe) {

            },
            callback: function () {

            }
        },],
        // class: "modal-lg",//modal-lg  modal-xl modal-sm
        class: "modal-xl",
        height: 400,
    },
        {}
    );

    sy.open(url, opt);
}
$(function () {

    $('.toolbartoken').toolbar('setFuncs', {
        //发送群聊消息
        addgroupmsg: function () {
            addgroupmsg();
        },
        //发送单聊消息
        addmsg: function () {
            var that = this;
            rowid = this.grid.jqGrid('getGridParam', 'selrow');
            if (!rowid) {
                return sy.tip('请选择要发送信息的记录!', 'warning');
            }
            rowdata = this.grid.jqGrid('getRowData', rowid);
            if (rowdata['kind'] == '自定义机器人')
                return sy.tip('自定义机器人只能发群聊消息!', 'warning');

            var url = sy.url({
                a: "addMsg",
                param: { id: rowid }
            });

            var opt = $.extend({
                title: '发送信息',
                cancel: true,
                // class: "modal-lg",//modal-lg  modal-xl modal-sm
                class: "modal-xl",
                height: 400,
                cancel: true,
                button: [{
                    name: '保存',
                    class: "btn-outline-primary",
                    submit: true,
                    close: true,
                    toolbar: that,
                    click: function (e, iframe) {

                    },
                    callback: function () {

                    }
                },]
            },
                {}
            );

            sy.open(url, opt);
        },
    });
})